layui.use(function(){
    var table = layui.table;
    var form = layui.form;
    var laydate = layui.laydate;
    // 创建表格实例
    table.render({
        elem: '#ID-table-demo-search',
        url: 'http://101.200.41.77:8080/area/list-back', // 此处为静态模拟数据，实际使用时需换成真实接口
        title:"分区表",
        cols: [[
            {checkbox: true, fixed: true},
            {field:'id', title: 'ID', sort: true,width:120, fixed: true},
            {field:'name', title: '分区名',edit:'text'},
            {field:'display_order', title: '显示顺序',width:120, edit:'text', sort: true},
            {field:'creator_name', title: '创建者',},
            {field:'post_count', title: '帖子数',width: 120},
            {field:'reply_count', title: '回复数', sort: true, width:120},
            {field: 'create_time',title: '创建时间'},
            {fixed: 'right',title: '操作',templet:'#toolbar'}
        ]],
        page: true,
        height: 310,
        toolbar:"#toolbarDemo",
        defaultToolbar: ['filter', 'exports', 'print']
    });
    // 日期
    laydate.render({
        elem: '.demo-table-search-date'
    });
    // 搜索提交
    form.on('submit(demo-table-search)', function(data){
        var field = data.field; // 获得表单字段
        // 执行搜索重载
        table.reload('ID-table-demo-search', {
            page: {
                curr: 1 // 重新从第 1 页开始
            },
            where: field // 搜索的字段
        });
        layer.msg('搜索成功<br>此处为静态模拟数据，实际使用时换成真实接口即可');
        return false; // 阻止默认 form 跳转
    });
});